package com.zzc.study.config;

import com.zzc.study.service.ChatAssistant;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
public class ChatLanguageModelConfig {
    @Bean
    public ChatLanguageModel chatLanguageModel(){
        return
                OpenAiChatModel.builder()
                        .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                        .modelName("qwen-plus")
                        .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                        .build();
    }
    /**
     * @Description: 出于与 OpenAI 兼容考虑，您也可以将 base_url 设置为 https://api.deepseek.com/v1 来使用，
     * 但注意，此处 v1 与模型版本无关。
     */
    /*@Bean  //  https://platform.deepseek.com/usage
    public ChatLanguageModel chatLanguageModel()
    {
        return
                OpenAiChatModel.builder()
                        .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                        .modelName("deepseek-chat")
                        //.modelName("deepseek-reasoner")
                        .baseUrl("https://api.deepseek.com/v1")
                        .build();
    }*/


    /**我们自定义的业务接口，yong aiservice完成了impl实现类编写
     public interface ChatAssistant
     {
     String chat(String prompt);
     }
     */
    // 你使用第2种类，高阶API    AiService
    @Bean
    public ChatAssistant chatAssistant(ChatLanguageModel chatLanguageModel)
    {
        return AiServices.create(ChatAssistant.class, chatLanguageModel);
    }

}
